import { pubRequire, pubRequireFree, downFile } from '@utils/msgPublic'
const baseUrl = '/messages'
const baseUrl1 = '/users'
export function templateList(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/templates`, params, callBack, errBack)
}

// 运营消息选择用户范围指定EXCEL导入学员UserId文件模板下载
export function download() {
  return `/messages/template/user_id/download`
}

//运营消息选择用户范围指定EXCEL导入学员大鹏号文件模板下载
export function downloadForDpCount() {
  return `/messages/template/dp_account/download`
}
//解析定向消息的用户数据的EXCEL上传文件
export function uploadFixedFile(params, callBack, errBack) {
  return pubRequire(
    'post',
    `${baseUrl}/file/task/targeted`,
    params,
    callBack,
    errBack
  )
}
// 解析运营消息选择用户范围指定EXCEL上传文件
export function uploadFile() {
  return `/messages/file/user_id/analysis`
}

//解析运营消息选择用户范围指定EXCEL导入大鹏号返回userId上传文件
export function uploadFileForDpCount() {
  return `/messages/file/dp_account/analysis`
}

// 消息列表展示
export function tasksList(params, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/operation/tasks`,
    params,
    callBack,
    errBack
  )
}

// 系统消息列表展示
export function sysTasksList(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/system/tasks`, params, callBack, errBack)
}

// 创建运营消息任务

export function createTemplate(params, sucBack, errorBack) {
  return pubRequireFree(
    'post',
    `${baseUrl}/tasks/operation-msg`,
    params,
    sucBack,
    errorBack
  )
}
//创建定点消息
export function createFixedMessage(params, sucBack, errorBack) {
  return pubRequireFree(
    'post',
    `${baseUrl}/tasks/targeted`,
    params,
    sucBack,
    errorBack
  )
}
//修改定点消息
export function complieFixedMessage(id, params, sucBack, errorBack) {
  return pubRequireFree(
    'put',
    `${baseUrl}/tasks/targeted/${id}`,
    params,
    sucBack,
    errorBack
  )
}
//定点消息下载模板
export function fixedMessageDownLoad(params, callBack, errBack) {
  return pubRequire(
    'get',
    `/messages/template/targeted/user/download`,
    params,
    callBack,
    errBack
  )
}

// 创建服务期到期消息任务
export function createService(params, sucBack, errorBack) {
  return pubRequireFree(
    'post',
    `${baseUrl}/tasks/expired-service-msg`,
    params,
    sucBack,
    errorBack
  )
}

// 获取已经发布学院列表

export function collegeList(params, callBack, errBack) {
  return pubRequire('get', `/colleges`, params, callBack, errBack)
}

// 消息详情展示  msgShow
export function messageDetail(id, params, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/operation/tasks/${id}/details`,
    params,
    callBack,
    errBack
  )
}

// 系统消息详情展示  msgShow
export function sysMessageDetail(id, params, callBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/system/tasks/${id}/details`,
    params,
    callBack,
    errBack
  )
}

// 根据学院id查询学院顾问数量
export function counselorNum(params, callBack, errBack) {
  return pubRequire('get', `/colleges/advisers/nums`, params, callBack, errBack)
}

// 查询通知学员数量 searchStudentNum timeNum
export function searchStudentNum(params, callBack, errBack) {
  return pubRequire(
    'get',
    `/orders/quantity/notice-users`,
    params,
    callBack,
    errBack
  )
}
// 根据订单类型查询服务期到期订单
export function serveList(params, callBack, errBack) {
  return pubRequire(
    'get',
    `/orders/quantity/overdue-orders`,
    params,
    callBack,
    errBack
  )
}

// 获取全部学员人数
export function studentAllStudent(params, callBack, errBack) {
  return pubRequire('get', `/users/quantity`, params, callBack, errBack)
}

// 用户接口登陆时间内的学员总数 userTime LoginTimeStudentCount

export function LoginTimeStudentCount(params, callBack, errBack) {
  return pubRequire('get', `/users/quantity/logged`, params, callBack, errBack)
}

// 用户获取学院下所有学员人数  college userGetAllStudent
export function collegeGetAllStudent(params, callBack, errBack) {
  return pubRequire(
    'get',
    `/users/quantity/colleges`,
    params,
    callBack,
    errBack
  )
}

// 消息发送数量详情 messagesDetailsnumber  postNumDetail
export function messagesDetailsNumber(id, params, callBack, errBack) {
  return pubRequire(
    'get',
    `/messages/tasks/${id}/details/statistics`,
    params,
    callBack,
    errBack
  )
}

// 获取手机号占位符
export function lastMobile(params, callBack, errBack) {
  return pubRequire(
    'get',
    '/messages/users/last-mobile',
    params,
    callBack,
    errBack
  )
}

// 下载导入Excel发送消息学员id

// 操作消息状态
export function changeStatus(id, obj, callbBack, errBack) {
  return pubRequireFree(
    'put',
    `/messages/tasks/${id}/status`,
    obj,
    callbBack,
    errBack
  )
}
// 查询任务详情 回显接口  templateData getSeachDetail
export function templateData(id, callBack, errBack) {
  return pubRequire(
    'get',
    `/messages/operation/tasks/${id}`,
    '',
    callBack,
    errBack
  )
}
//查询任务详情 回显接口
export function serverTemplateData(id, callBack, errBack) {
  return pubRequire('get', `/messages/tasks/${id}`, '', callBack, errBack)
}

// 修改运营消息
// changeTemplate  compileOperation
export function compileOperation(id, obj, callbBack, errBack) {
  return pubRequireFree(
    'put',
    `/messages/tasks/operation-msg/${id}`,
    obj,
    callbBack,
    errBack
  )
}

// 长链接转短链接
// turnChain
export function turnChain(params, callBack, errBack) {
  return pubRequire('post', `/links/convert`, params, callBack, errBack)
}

// 编辑服务期到期消息任务
// compileService changeServe
export function compileService(id, obj, callbBack, errBack) {
  return pubRequireFree(
    'put',
    `/messages/tasks/expired-service-msg/${id}`,
    obj,
    callbBack,
    errBack
  )
}

// 修改系统模板开启状态
export function updateOpenStatus(id, obj, callbBack, errBack) {
  return pubRequireFree(
    'put',
    `/messages/templates/system/${id}/send_status`,
    obj,
    callbBack,
    errBack
  )
}

// 查询系统消息任务详情
export function systemTaskDetails(id, params, callBack, errBack) {
  return pubRequire(
    'get',
    `/messages/system/tasks/${id}`,
    params,
    callBack,
    errBack
  )
}

// 修改系统消息
export function compileSystemTask(id, obj, callbBack, errBack) {
  return pubRequireFree(
    'put',
    `/messages/system/tasks/${id}`,
    obj,
    callbBack,
    errBack
  )
}

//撤回已发送和发送中的运营消息
export function withdrawCompileOperation(id, obj, callbBack, errBack) {
  return pubRequireFree(
    'put',
    `/messages/${id}/recall`,
    obj,
    callbBack,
    errBack
  )
}

//根据角色id查询所有用户信息
export function getUsers(obj, callbBack, errBack) {
  return pubRequire('post', `${baseUrl1}/by-roles`, obj, callbBack, errBack)
}
//获取活动类型
export function activityTypes(obj, callbBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/activity/activity-types`,
    obj,
    callbBack,
    errBack
  )
}
//创建活动消息
export function createActivity(obj, callbBack, errBack) {
  return pubRequire(
    'post',
    `${baseUrl}/tasks/activity`,
    obj,
    callbBack,
    errBack
  )
}
//活动消息列表
export function activityList(obj, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/activity/tasks`, obj, callbBack, errBack)
}
//修改活动消息
export function editActivity(id, obj, callbBack, errBack) {
  return pubRequireFree(
    'put',
    `${baseUrl}/activity/tasks/${id}`,
    obj,
    callbBack,
    errBack
  )
}
// 上传附件
export function uploadAccessory(params, sucBack, errorBack) {
  return pubRequireFree(
    'post',
    `/system/files/upload`,
    params,
    sucBack,
    errorBack
  )
}
